1. Technical Field
The invention relates to compilers. More particularly, the invention relates to a unique procedure for global element optimization within a compiler.
2. Description of the Prior Art
FIG. 1 is a block schematic diagram of a uniprocessor computer architecture 10, including a processor cache. In FIG. 1, a processor 11 includes a cache 12 which is in communication with a system bus 15. A system memory 13 and one or more I/O devices 14 are also in communication with the system bus.
FIG. 2 is a block schematic diagram of a software compiler 20, for example as may be used in connection with the computer architecture 10 shown in FIG. 1. The compiler Front End component 21 reads a source code file (100) and translates it into a high level intermediate representation (110). A high level optimizer 22 optimizes the high level intermediate representation 110 into a more efficient form. A code generator 23 translates the optimized high level intermediate representation to a low level intermediate representation (120).
The low level optimizer 24 converts the low level intermediate representation (120) into a more efficient (machine-executable) form. Finally, an object file generator 25 writes out the optimized low-level intermediate representation into an object file (141). The object file (141) is processed along with other object files (140) by a linker 26 to produce an executable file (150), which can be run on the computer 10.
The compiler is the piece of software that translates the source code of a programmer written in a programming language, such as C, BASIC, or FORTRAN, into a binary image (i.e. the object code) that actually runs on a machine. Program written in the C/C++ language have two types of program elements, i.e. global elements and static (or file local) elements. Some systems, such as those manufactured by Computer Graphics, Inc. of Mountain View, Calif., impose a hard limit on the number of global elements that a given program may have. Usually there is no limit on the number of static elements within a program.
In traditional C code, the limit on global elements is usually avoided by declaring program elements as static whenever possible. Because of the nature of C++, this tactic is not effective. Making program elements static is difficult without compromising the model of development that C++ requires of the programmer. As a result, C++ programs tend to have a much higher global element count than for the same program implemented in C. It should be noted that this problem is not specific to C++. Rather, CC++ tends to highlight the problem, and offers no direct way to address it.
The problem of a high global element count has been addressed in the past by breaking the program into two or more pieces. Each program component (library) has the same limit of global elements that the original program had, such that the number of global elements available is increased significantly by breaking the program into two or more pieces. However, instead of delivering the program as one file, the prior approach to solving the global element limitation problem requires that the program be delivered as two or more files. This makes such tasks as installation and administration much more difficult. For example, in Unix systems this approach changes the model of use significantly.
It would be advantageous to provide an optimization technique that allows a programmer to produce a program without requiring that the program be broken into two or more pieces because a limit on global elements has been exceeded as a result of the program size.